package com.ryder.subject.application.controller;

import com.alibaba.fastjson2.JSON;
import com.ryder.subject.common.entity.PageResult;
import com.ryder.subject.infra.basic.entity.SubjectInfoEs;
import com.ryder.subject.infra.basic.service.SubjectEsService;
import com.ryder.subject.infra.entity.UserInfo;
import com.ryder.subject.infra.rpc.UserRPC;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 描述:
 *
 * @author Ryder
 * @version 1.0
 * @date 2025/02/03
 * @since 1.0 // 版本号，指明从哪个版本开始
 */

@RestController
@RequestMapping("/subject/category")
@Slf4j
public class TestFeignController {

    @Autowired
    private UserRPC userRPC;

    @Autowired
    private SubjectEsService subjectEsService;

    @GetMapping("testFeign")
    public void testFeign() {
        UserInfo userInfo = userRPC.getUserInfo("ryder");
        log.info("TestFeignController.testFeign.userInfo:{}", userInfo);
    }

    @PostMapping("querySubjectByKeyword")
    public void querySubjectByKeyword() {
        SubjectInfoEs subjectInfoEs = new SubjectInfoEs();
        subjectInfoEs.setKeyWord("mysql");
        PageResult<SubjectInfoEs> subjectInfoEsPageResult = subjectEsService.querySubjectList(subjectInfoEs);
        log.info("TestFeignController.querySubjectByKeyword.subjectInfoEsPageResult:{}", JSON.toJSONString(subjectInfoEsPageResult));
    }

}
